<template>
	<view class="slide-main">
		<view class="list" v-for="(item,index) in renderData" :key="index" @click="clickItem(item)">
			<!-- <liu-swipe-action ref="swipe" :index="index" @clickItem="clickItem" > -->
			<view class="item">
				<view>{{item.name}}</view>
				<view class="item-name">{{item.content}}</view>
				<view class="item-name">{{item.date}}</view>
			</view>
			<!-- </liu-swipe-action> -->
		</view>
		<view class="btnBox">
			<button class="btn" @click="toAdd">新增任务</button>
		</view>
	</view>
</template>

<script>
	import {
		baseURL
	} from '@/api/env.js'
	export default {
		data() {
			return {
				list: [{
					id: 1,
					name: '任务1',
					date: '2023-09-18',
					type: 0,
					content: '内容1'
				}, {
					id: 2,
					name: '任务2',
					date: '2023-10-18',
					type: 1,
					content: '内容2'
				}],
				renderData: [],
				indexs: 0

			}
		},
		onShow() {
			this.getTaskConfigList()
		},
		onLoad() {
			this.getTaskConfigList()
		},
		mounted() {
			console.log("refs:", this.$refs.swipe)
		},
		methods: {
			//点击操作回调事件
			clickItem(item) {
				uni.navigateTo({
					url: '/pages/taskMg/setTask/addTask/addTask?item=' + JSON.stringify(item)
				})
			},
			// 新增
			toAdd() {
				uni.navigateTo({
					url: '/pages/taskMg/setTask/addTask/addTask'
				})
			},
			refreshPage(data) {
				// 执行刷新页面的操作，并设置data值
				this.dataValue = data;
			},
			/**
			 *接口
			 * /
			 */
			// 获取分页
			getTaskConfigList() {
				uni.request({
					url: baseURL + '/api/task/config/page',
					method: "GET",
					header: {
						// "content-type": "appLication/x-www-form-urlencoded",
						'Authorization': uni.getStorageSync('token')
					},
					success: (res) => {
						console.log('getTaskConfigList', res.data.data);
						this.renderData = res.data.data.records
						this.total = res.data.data.total
					}
				})
			}
			// 
		}
	}
</script>

<style scoped lang="scss">
	.slide-main {
		width: 100%;
		height: 90vh;
		overflow-y: auto;
		/* background-color: #f0f0f0; */
	}

	.list {
		width: calc(100% - 40rpx);
		margin-top: 20rpx;
	}

	.item {
		width: calc(100% - 40rpx);
		height: 120rpx;
		font-size: 1.2rem;
		background-color: #ffffff;
		margin: 0 20rpx 20rpx 20rpx;
		padding: 20rpx;
		border-radius: 10rpx;

		display: flex;
		flex-direction: column;
		/* align-items: center; */
		justify-content: space-around;
	}

	/* .item-img {
        width: 80rpx;
        height: 80rpx;
        border-radius: 50%;
        margin-left: 28rpx;
    } */

	.item-name {
		font-size: 0.8rem;
		color: #d4d4d4;
	}

	.btnBox {
		position: fixed;
		bottom: 3%;
		z-index: 1000;

		.btn {
			width: calc(100vw - 200rpx);
			height: 80rpx;
			line-height: 80rpx;
			font-size: 0.8rem;
			color: white;
			margin-left: 100rpx;
			border-radius: 40rpx;
			background-color: #409EFF;
		}
	}
</style>